home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NeXTSTEP 3.1 (Developer) [x86]
/
NeXT Step 3.1 Intel dev.cdr.dmg
/
NextDeveloper
/
Examples
/
AppKit
/
Draw
/
graphicsUndo.subproj
/
GridChange.m
< prev
next >
Wrap
Text File
|
1992-02-09
|
2KB
|
77 lines
#import "drawundo.h"
@interface GridChange(PrivateMethods)
@end
@implementation GridChange
- initGraphicView:aGraphicView
{
[super init];
graphicView = aGraphicView;
return self;
}
- (const char *)changeName
{
return NXLocalStringFromTable("Operations", "Grid Change", NULL, "The operation of changing the spacing or color of the grid.");
}
- saveBeforeChange
{
oldSpacing = [graphicView gridSpacing];
oldGray = [graphicView gridGray];
oldVisible = [graphicView gridIsVisible];
oldEnabled = [graphicView gridIsEnabled];
return self;
}
- undoChange
{
newSpacing = [graphicView gridSpacing];
newGray = [graphicView gridGray];
newVisible = [graphicView gridIsVisible];
newEnabled = [graphicView gridIsEnabled];
[[self changeManager] disableChanges:self];
[graphicView setGridSpacing:oldSpacing andGray:oldGray];
[graphicView setGridVisible:oldVisible];
[graphicView setGridEnabled:oldEnabled];
[[self changeManager] enableChanges:self];
return [super undoChange];
}
- redoChange
{
[[self changeManager] disableChanges:self];
[graphicView setGridSpacing:newSpacing andGray:newGray];
[graphicView setGridVisible:newVisible];
[graphicView setGridEnabled:newEnabled];
[[self changeManager] enableChanges:self];
return [super redoChange];
}
- (BOOL)subsumeChange:change
/*
* ChangeManager will call subsumeChange: when we are the last
* completed change and a new change has just begun. We override
* the subsumeChange: because we want to consolidate multiple
* grid changes into a single change. For example, if the user
* selects the menu item "Show Grid" and then selects the menu
* item "Turn Grid On", we'll only leave a single GridChange in
* the ChangeManager's list of changes.Both changes can then be
* be undone and redone in one action.
*/
{
if ([change isKindOf:[GridChange class]]) {
[self saveBeforeChange];
return YES;
} else {
return NO;
}
}
@end